﻿using ET.Monitor.DAL;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ET.Monitor.Model
{
    public class OrgModel
    {
        string oid, orgParentId, orgNameCn, installDate, longitude, nationId, completeDate, networkDate, orientation, angle, capacity,
                latitude, level1, level2, level3, eleUnitPrice, irrandiance, month1Expected, month2Expected, month3Expected,
                month4Expected, month5Expected, month6Expected, month7Expected, month8Expected, month9Expected, month10Expected,
                month11Expected, month12Expected;

        OrgDAL dal = new OrgDAL();
        public OrgModel() { }
        public OrgModel(string orgid)
        {
            oid = orgid;
        }

        public OrgModel(string orgId, string parentId, string nameCn)
        {
            oid = orgId;
            orgParentId = parentId;
            orgNameCn = nameCn;
        }

        public OrgModel(string orgId, string longitude, string latitude, string installDate, string level1, string level2,
                        string level3, string unitPrice, string irrandiance, string month1, string month2, string month3,
                        string month4, string month5, string month6, string month7, string month8, string month9, string month10, string month11, string month12)
        {
            oid = orgId;
            this.longitude = longitude;
            this.latitude = latitude;
            this.installDate = installDate;
            this.level1 = level1;
            this.level2 = level2;
            this.level3 = level3;
            this.eleUnitPrice = unitPrice;
            this.irrandiance = irrandiance;
            this.month1Expected = month1;
            this.month2Expected = month2;
            this.month3Expected = month3;
            this.month4Expected = month4;
            this.month5Expected = month5;
            this.month6Expected = month6;
            this.month7Expected = month7;
            this.month8Expected = month8;
            this.month9Expected = month9;
            this.month10Expected = month10;
            this.month11Expected = month11;
            this.month12Expected = month12;
        }

        public OrgModel(string id, string pid, string name, string lon, string lat, string creatTime, string completeTime, string netTime, string orien, string angle, string capacity,
                        string month1, string month2, string month3, string month4, string month5, string month6, string month7, string month8, string month9, string month10, string month11, string month12)
        {
            this.oid = id;
            this.orgParentId = pid;
            this.orgNameCn = name;
            this.longitude = lon;
            this.latitude = lat;
            this.installDate = creatTime;
            this.completeDate = completeTime;
            this.networkDate = netTime;
            this.orientation = orien;
            this.angle = angle;
            this.capacity = capacity;
            this.month1Expected = month1;
            this.month2Expected = month2;
            this.month3Expected = month3;
            this.month4Expected = month4;
            this.month5Expected = month5;
            this.month6Expected = month6;
            this.month7Expected = month7;
            this.month8Expected = month8;
            this.month9Expected = month9;
            this.month10Expected = month10;
            this.month11Expected = month11;
            this.month12Expected = month12;
        }

        DataTable dtOrgInfo;

        public DataTable DtOrgInfo
        {
            get { return dal.GetOrgInfo(oid); }
            set { dtOrgInfo = value; }
        }
        DataTable dtParentOrginfo;

        public DataTable DtParentOrginfo
        {
            get { return dal.GetOrgParentInfo(oid); }
            set { dtParentOrginfo = value; }
        }
        DataTable dtSunOrgInfo;

        public DataTable DtSunOrgInfo
        {
            get { return dal.GetOrgSunInfo(oid); }
            set { dtSunOrgInfo = value; }
        }

        DataTable dtSunOrgInfos;

        public DataTable DtSunOrgInfos
        {
            get { return dal.GetOrgSunInfos(oid); }
            set { dtSunOrgInfos = value; }
        }

        DataTable dtOrgAreaInfo;

        public DataTable DtOrgAreaInfo
        {
            get { return dal.GetOrgAreaInfo(oid); }
            set { dtOrgAreaInfo = value; }
        }

        bool addOrg;

        public bool AddOrg
        {
            get { return dal.AddOrgModel(oid, orgParentId, orgNameCn); }
            set { addOrg = value; }
        }

        bool addFRPlant;

        public bool AddFRPlant
        {
            get
            {
                return dal.AddFRPlantInfo(oid, orgParentId, orgNameCn, longitude, latitude, installDate, completeDate, networkDate, orientation, angle, capacity,
                      month1Expected, month2Expected, month3Expected, month4Expected, month5Expected, month6Expected, month7Expected,
                            month8Expected, month9Expected, month10Expected, month11Expected, month12Expected);
            }
            set
            {
                addFRPlant = value;
            }
        }

        bool editFRPlant;

        public bool EditFRPlant
        {
            get
            {
                return dal.UpdateFRPlantInfo(oid, orgNameCn, longitude, latitude, installDate, completeDate, networkDate, orientation, angle, capacity,
                    month1Expected, month2Expected, month3Expected, month4Expected, month5Expected, month6Expected, month7Expected, month8Expected, month9Expected, month10Expected, month11Expected, month12Expected);
            }

            set
            {
                editFRPlant = value;
            }
        }

        bool delOrg;

        public bool DelOrg
        {
            get { return dal.DeleteOrgModelById(oid); }
            set { delOrg = value; }
        }

        bool delPlantInfo;

        public bool DelPlantInfo
        {
            get { return dal.DeletePlantInfo(oid); }
            set { delPlantInfo = value; }
        }

        bool updateOrg;

        public bool UpdateOrg
        {
            get { return dal.UpdateOrgModel(oid, orgNameCn); }
            set { updateOrg = value; }
        }

        bool addPlantInfo;

        public bool AddPlantInfo
        {
            get
            {
                return dal.AddPlantDetailInfo(oid, longitude, latitude, installDate, level1, level2, level3, eleUnitPrice, irrandiance,
                              month1Expected, month2Expected, month3Expected, month4Expected, month5Expected, month6Expected, month7Expected,
                              month8Expected, month9Expected, month10Expected, month11Expected, month12Expected);
            }
            set { addPlantInfo = value; }
        }

        bool editPlantInfo;

        public bool EditPlantInfo
        {
            get
            {
                return dal.UpdatePlantInfo(oid, longitude, latitude, installDate, level1, level2, level3, eleUnitPrice, irrandiance,
                          month1Expected, month2Expected, month3Expected, month4Expected, month5Expected, month6Expected, month7Expected,
                              month8Expected, month9Expected, month10Expected, month11Expected, month12Expected);
            }
            set { editPlantInfo = value; }
        }

        #region 获取所有组织机构信息
        DataTable dtAllOrgInfo;

        public DataTable DtAllOrgInfo
        {
            get { return dal.GetAllOrgInfo(); }
            set { dtAllOrgInfo = value; }
        }

        public DataTable AllOrgStationInfo
        {
            get { return dal.GetAllOrgStationInfo(oid); }
            set { dtAllOrgInfo = value; }
        }
        #endregion

        #region
        DataTable dtCity;
        public DataTable DtCity
        {
            get
            {
                return dal.GetCity();
            }

            set
            {
                dtCity = value;
            }
        }
        #endregion

        #region  获取某个用户下面的所有组织机构
        DataTable dtUserAuthorization;

        public DataTable DtUserAuthorization
        {
            get { return dal.GetUserAuthorization(oid); }
            set { dtUserAuthorization = value; }
        }

        #endregion

        #region  某个用户下面所有电站
        DataTable dtUserStation;

        public DataTable DtUserStation
        {
            get
            {
                return dal.GetUserStation(oid);
            }

            set
            {
                dtUserStation = value;
            }
        }

        public DataTable DtPlantOrgInfo
        {
            get
            {
                return dal.GetPlantInfoById(oid);
            }

            set
            {
                dtPlantOrgInfo = value;
            }
        }


        DataTable dtPlantOrgInfo;



        public List<string> GroupInfo
        {
            get
            {
                return dal.GetGroupInfoById(oid);
            }
        }



        #endregion

        #region 市
        string strCity;
        public string StrCity
        {
            get
            {
                return dal.GetCity(oid);
            }

            set
            {
                strCity = value;
            }
        }
        #endregion

        #region
        string strPrivince;

        public string StrPrivince
        {
            get
            {
                return dal.GetPrivince(oid);
            }

            set
            {
                strPrivince = value;
            }
        }

        public IList<Hashtable> List
        {
            get
            {
                return dal.GetCityByPrivince(oid);
            }

            set
            {
                list = value;
            }
        }
        #endregion

        #region
        IList<Hashtable> list;
        #endregion
    }
}
